#region <<版权版本注释>>

// ----------------------------------------------------------------
// Copyright ©2021-Present ZhaiFanhua All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// FileName:UserDto
// Guid:2a2b3c4d-5e6f-7890-abcd-ef1234567891
// Author:zhaifanhua
// Email:me@zhaifanhua.com
// CreateTime:2025/10/31 4:00:00
// ----------------------------------------------------------------

#endregion <<版权版本注释>>

using XiHan.BasicApp.Rbac.Dtos.Base;
using XiHan.BasicApp.Rbac.Enums;

namespace XiHan.BasicApp.Rbac.Dtos.Users;

/// <summary>
/// 用户 DTO
/// </summary>
public class UserDto : RbacFullAuditedDtoBase
{
    /// <summary>
    /// 租户ID
    /// </summary>
    public RbacIdType? TenantId { get; set; }

    /// <summary>
    /// 用户名
    /// </summary>
    public string UserName { get; set; } = string.Empty;

    /// <summary>
    /// 真实姓名
    /// </summary>
    public string? RealName { get; set; }

    /// <summary>
    /// 昵称
    /// </summary>
    public string? NickName { get; set; }

    /// <summary>
    /// 头像
    /// </summary>
    public string? Avatar { get; set; }

    /// <summary>
    /// 邮箱
    /// </summary>
    public string? Email { get; set; }

    /// <summary>
    /// 手机号
    /// </summary>
    public string? Phone { get; set; }

    /// <summary>
    /// 性别
    /// </summary>
    public UserGender Gender { get; set; }

    /// <summary>
    /// 生日
    /// </summary>
    public DateTimeOffset? Birthday { get; set; }

    /// <summary>
    /// 状态
    /// </summary>
    public YesOrNo Status { get; set; }

    /// <summary>
    /// 最后登录时间
    /// </summary>
    public DateTimeOffset? LastLoginTime { get; set; }

    /// <summary>
    /// 最后登录IP
    /// </summary>
    public string? LastLoginIp { get; set; }

    /// <summary>
    /// 时区
    /// </summary>
    public string? TimeZone { get; set; }

    /// <summary>
    /// 语言
    /// </summary>
    public string? Language { get; set; }

    /// <summary>
    /// 国家/地区
    /// </summary>
    public string? Country { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    public string? Remark { get; set; }
}

/// <summary>
/// 用户详情 DTO
/// </summary>
public class UserDetailDto : UserDto
{
    /// <summary>
    /// 用户角色列表
    /// </summary>
    public List<RbacIdType> RoleIds { get; set; } = [];

    /// <summary>
    /// 用户角色名称列表
    /// </summary>
    public List<string> RoleNames { get; set; } = [];

    /// <summary>
    /// 用户部门列表
    /// </summary>
    public List<RbacIdType> DepartmentIds { get; set; } = [];

    /// <summary>
    /// 用户部门名称列表
    /// </summary>
    public List<string> DepartmentNames { get; set; } = [];

    /// <summary>
    /// 用户权限列表
    /// </summary>
    public List<string> Permissions { get; set; } = [];
}

/// <summary>
/// 创建用户 DTO
/// </summary>
public class CreateUserDto : RbacCreationDtoBase
{
    /// <summary>
    /// 租户ID
    /// </summary>
    public RbacIdType? TenantId { get; set; }

    /// <summary>
    /// 用户名
    /// </summary>
    public string UserName { get; set; } = string.Empty;

    /// <summary>
    /// 密码
    /// </summary>
    public string Password { get; set; } = string.Empty;

    /// <summary>
    /// 真实姓名
    /// </summary>
    public string? RealName { get; set; }

    /// <summary>
    /// 昵称
    /// </summary>
    public string? NickName { get; set; }

    /// <summary>
    /// 头像
    /// </summary>
    public string? Avatar { get; set; }

    /// <summary>
    /// 邮箱
    /// </summary>
    public string? Email { get; set; }

    /// <summary>
    /// 手机号
    /// </summary>
    public string? Phone { get; set; }

    /// <summary>
    /// 性别
    /// </summary>
    public UserGender Gender { get; set; } = UserGender.Unknown;

    /// <summary>
    /// 生日
    /// </summary>
    public DateTimeOffset? Birthday { get; set; }

    /// <summary>
    /// 时区
    /// </summary>
    public string? TimeZone { get; set; }

    /// <summary>
    /// 语言
    /// </summary>
    public string? Language { get; set; } = "zh-CN";

    /// <summary>
    /// 国家/地区
    /// </summary>
    public string? Country { get; set; }

    /// <summary>
    /// 角色ID列表
    /// </summary>
    public List<RbacIdType> RoleIds { get; set; } = [];

    /// <summary>
    /// 部门ID列表
    /// </summary>
    public List<RbacIdType> DepartmentIds { get; set; } = [];

    /// <summary>
    /// 备注
    /// </summary>
    public string? Remark { get; set; }
}

/// <summary>
/// 更新用户 DTO
/// </summary>
public class UpdateUserDto : RbacUpdateDtoBase
{
    /// <summary>
    /// 真实姓名
    /// </summary>
    public string? RealName { get; set; }

    /// <summary>
    /// 昵称
    /// </summary>
    public string? NickName { get; set; }

    /// <summary>
    /// 头像
    /// </summary>
    public string? Avatar { get; set; }

    /// <summary>
    /// 邮箱
    /// </summary>
    public string? Email { get; set; }

    /// <summary>
    /// 手机号
    /// </summary>
    public string? Phone { get; set; }

    /// <summary>
    /// 性别
    /// </summary>
    public UserGender? Gender { get; set; }

    /// <summary>
    /// 生日
    /// </summary>
    public DateTimeOffset? Birthday { get; set; }

    /// <summary>
    /// 状态
    /// </summary>
    public YesOrNo? Status { get; set; }

    /// <summary>
    /// 时区
    /// </summary>
    public string? TimeZone { get; set; }

    /// <summary>
    /// 语言
    /// </summary>
    public string? Language { get; set; }

    /// <summary>
    /// 国家/地区
    /// </summary>
    public string? Country { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    public string? Remark { get; set; }
}

/// <summary>
/// 修改密码 DTO
/// </summary>
public class ChangePasswordDto
{
    /// <summary>
    /// 用户ID
    /// </summary>
    public RbacIdType UserId { get; set; }

    /// <summary>
    /// 旧密码
    /// </summary>
    public string OldPassword { get; set; } = string.Empty;

    /// <summary>
    /// 新密码
    /// </summary>
    public string NewPassword { get; set; } = string.Empty;

    /// <summary>
    /// 确认密码
    /// </summary>
    public string ConfirmPassword { get; set; } = string.Empty;
}

/// <summary>
/// 重置密码 DTO
/// </summary>
public class ResetPasswordDto
{
    /// <summary>
    /// 用户ID
    /// </summary>
    public RbacIdType UserId { get; set; }

    /// <summary>
    /// 新密码
    /// </summary>
    public string NewPassword { get; set; } = string.Empty;
}

/// <summary>
/// 分配角色 DTO
/// </summary>
public class AssignUserRolesDto
{
    /// <summary>
    /// 用户ID
    /// </summary>
    public RbacIdType UserId { get; set; }

    /// <summary>
    /// 角色ID列表
    /// </summary>
    public List<RbacIdType> RoleIds { get; set; } = [];
}

/// <summary>
/// 分配部门 DTO
/// </summary>
public class AssignUserDepartmentsDto
{
    /// <summary>
    /// 用户ID
    /// </summary>
    public RbacIdType UserId { get; set; }

    /// <summary>
    /// 部门ID列表
    /// </summary>
    public List<RbacIdType> DepartmentIds { get; set; } = [];
}